package com.hdu.myMabatisAop;

import java.util.ArrayList;
import java.util.List;

public class InterceptorChain {


    private static final List<Interceptor> INTERCEPTORS = new ArrayList<>();

    public static Object pluginAll(Object target) {
        for (Interceptor interceptor : INTERCEPTORS) {
            target = interceptor.plugin(target);
        }
        return target;
    }

    public static void addInterceptor(Interceptor interceptor) {
        INTERCEPTORS.add(interceptor);
    }

}
